class CreateCandidates < ActiveRecord::Migration
  def self.up
    create_table :candidates do |t|
      t.string :name, :limit => 80, :null => false
      t.text :description
      t.integer :votes_count, :default => 0
      t.integer :election_id, :null => false, :on_delete => :cascade
      t.auto_dates
    end
    add_index :candidates, [:name, :election_id], :unique => true
  end

  def self.down
    drop_table :candidates
  end
end
